#include <stdio.h>
#include <stdlib.h>
//leetCode 191
//Given a positive integer n, write a function that 
//returns the number of in its binary representation 
//(also known as the Hamming weight).

int hammingWeight(int n) {
    if (n==0) 
        return 0;
    else {
        if (n & 0x1) 
            return hammingWeight( n>>1 ) + 1;
        else
            return hammingWeight( n>>1 );
    }
}

int main(int argc, char *argv[]) {
    int x = atoi(argv[1]);

    printf("%d hamming weight = %d\n", x, hammingWeight(x));
}